package com.xdh.zzqh.utils

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.xdh.zzqh.R


private class OrderCellItemView(view: View) : RecyclerView.ViewHolder(view) {

    private val tv = view.findViewById<TextView>(R.id.id_item_table_tv)

    fun setUp(s: String) {
        tv.text = s
    }
}

private class OrderAdapter(val list: List<String>) : RecyclerView.Adapter<OrderCellItemView>() {

    override fun getItemCount(): Int {
        return list.size
    }

    override fun onBindViewHolder(holder: OrderCellItemView, position: Int) {
        holder.setUp(list[position])
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): OrderCellItemView {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.item_table, parent, false)
        return OrderCellItemView(view)
    }
}


fun setOrder(rv: RecyclerView, list: List<String>) {
    rv.layoutManager = GridLayoutManager(rv.context, 11)
    rv.isNestedScrollingEnabled = false
    rv.adapter = OrderAdapter(list)
}










